/************************************************************************************
* MediaItem.cpp                                                                     *
*                                                                                   *
* Copyright (C) 2011 Varuna L Amachi                                                *
*                                                                                   *
* This program is free software; you can redistribute it and/or modify              *
* it under the terms of the GNU General Public License as published by              *
* the Free Software Foundation; either version 2 of the License, or any             *
* later version.                                                                    *
*                                                                                   *
* This program is distributed in the hope that it will be useful, but               *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY        *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for       *
* more details. You should have received a copy of the GNU General Public           *
* License along with this program; if not, write to the Free Software Foundation,   *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                       *
*                                                                                   *
*************************************************************************************/

#include "MediaItem.h"

QString MediaItem::FILE_SYSTEM_ITEM = "FILE_SYSTEM_ITEM";

using namespace Phonon;

MediaItem::MediaItem(QString uuid, MediaSource *source) :
    m_trackId(uuid), m_source(source){

}

void MediaItem::setMetaData(
          QString trackName,
          QString artistName,
          QString albumName ,
          QString date ,
          QString genre ,
          QString desc,
          int trackNum,
          int lengthInSec,
          int bitRate,
          int sampleRate,
          int channels) {
    if(trackName != "") {
        m_trackName  = trackName;
    }
    else {
        m_trackName = m_source->fileName().right(
                    m_source->fileName().size() -
                    m_source->fileName().lastIndexOf("/")-1);

    }
    m_artistName = artistName;
    m_albumName  = albumName;
    m_date       = date;
    m_genre      = genre;
    m_trackNumber= trackNum;
    m_description= desc;
    m_bitRate    = bitRate;
    m_sampleRate = sampleRate;
    m_channels   = channels;
    m_duration   = lengthInSec;
}


QString MediaItem::trackId() {
    return  m_trackId;
}

QString MediaItem::title() {
    return m_trackName;
}

QString MediaItem::artist()  {
    return m_artistName;
}


QString MediaItem::album() {
    return m_albumName;
}


QString MediaItem::date() {
    return m_date;
}


QString MediaItem::genre() {
    return m_genre;
}


int MediaItem::trackNumber() {
    return m_trackNumber;
}


QString MediaItem::description() {
    return m_description;
}


int MediaItem::duration() {
    return m_duration;
}


int MediaItem::bitrate() {
    return m_bitRate;
}


int MediaItem::sampleRate() {
    return m_sampleRate;
}


int MediaItem::numChannels() {
    return m_channels;
}


MediaSource* MediaItem::source() {
    return m_source;
}



MediaItem::~MediaItem() {
    delete m_source;
}


QString MediaItem::itemType() {
    return FILE_SYSTEM_ITEM;
}

//God help me
bool MediaItem::operator ==(MediaItem& other) {
    return m_trackId == other.trackId();
}
